package com.xiaowei.gym.gymjsp.ware.service.impl;

import com.xiaowei.gym.gymjsp.ware.dao.ReservationDao;
import com.xiaowei.gym.gymjsp.ware.dao.impl.ReservationDaoImpl;
import com.xiaowei.gym.gymjsp.ware.entity.ReservationEntity;
import com.xiaowei.gym.gymjsp.ware.service.ReservationService;

import java.util.List;

public class ReservationServiceImpl implements ReservationService {

    private ReservationDao reservationDao;

    public ReservationServiceImpl() {
        reservationDao = new ReservationDaoImpl();
    }

    @Override
    public List<ReservationEntity> getResevationList(Integer member_id, int currentPageNo, Integer pageSize) {
        return reservationDao.getList(member_id,currentPageNo,pageSize);
    }

    @Override
    public int getCount() {
        return reservationDao.getCount();
    }

    @Override
    public boolean addReservation(ReservationEntity reservationEntity) {
        int i = reservationDao.createReservation(reservationEntity);
        if (i > 0){
            return true;
        }
        return false;
    }

    @Override
    public ReservationEntity getReservationById(Integer valueOf) {
        return reservationDao.getById(valueOf);
    }

    @Override
    public boolean modify(ReservationEntity reservationEntity) {
        int i = reservationDao.modify(reservationEntity);
        if (i > 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean delreservationByIds(Integer[] delId) {
        int[] ints = reservationDao.delByIds(delId);
        if (ints.length > 0 || ints != null){
            return true;
        }
        return false;
    }
}
